//
//  LCMyTableViewController.m
//  SLYTravel
//
//  Created by 吕超 on 16/5/18.
//  Copyright © 2016年 锁腾飞. All rights reserved.
//

#import "LCMyTableViewController.h"

@interface LCMyTableViewController ()<UIAlertViewDelegate>

@property (nonatomic, strong)NSArray *MyTableArray;

@end

@implementation LCMyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.bounces = NO;
    

    //样式白色
<<<<<<< HEAD
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
=======
    [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];
>>>>>>> 12a33b3d2b89ccec9b9a0edf1985ffae3a9cc596

    
    [self CreateSubControl];
    
    _MyTableArray = @[@[@"tab_activities",@"我的游记"],@[@"NavBar_AppShare", @"我的收藏"], @[@"nav_settings", @"设置"]];
    
    self.tableView.tableFooterView = [[UIView alloc]init];
}




//创建 设置 子控件
- (void)CreateSubControl{
    //圆角效果  动画效果没有切角失效
    _headImageView.layer.masksToBounds = YES;
    //高的一半切成圆
    _headImageView.layer.cornerRadius = _headImageView.frame.size.height/2;
    //设置边框颜色
    _headImageView.layer.borderColor = [UIColor whiteColor].CGColor;
    //设置边框宽度
    _headImageView.layer.borderWidth = 4;
    //设置边界外内容不显示
    _headImageView.clipsToBounds = YES;
    _headImageView.backgroundColor = [UIColor redColor];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.MyTableArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *Identifier = @"LCMycell";
    
    UITableViewCell *cell =  [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];

    
    cell.backgroundColor = [UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:1];
    cell.textLabel.font = [UIFont systemFontOfSize:13];
    
    
    NSArray * arr = _MyTableArray[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:arr[0]];
    cell.textLabel.text = arr[1];
    
    //  添加  计发表次数 lable
    switch (indexPath.row) {
        case 0 : {
            
            _FaBiaoNumber = [[UILabel alloc]initWithFrame:CGRectMake(selfWidth - 80, 5, 60, 34)];
            _FaBiaoNumber.textAlignment = NSTextAlignmentRight;
            _FaBiaoNumber.text = @"55";
            //            _FaBiaoNumber.backgroundColor = [UIColor redColor];
            [cell addSubview:self.FaBiaoNumber];
            break;
        }
        default:
            //右边有一个小箭头
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
    }
    return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:
            
            
            break;
        case 1:
            
            
            break;
        case 2:
        {
            // 第一个空是最上面标题  第二个空是显示内容  第三个空是喜欢的类型 居中
            UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"设置" message:@"可以清除缓存的" preferredStyle:UIAlertControllerStyleActionSheet];

             __weak typeof(self) WeakSelf = self;
               UIAlertAction *ac1 = [UIAlertAction actionWithTitle:@"清除缓存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                   //清除缓存
                   [WeakSelf clearCache];
               }];
            
            
            // 第一空button上文字  第二空 添加红色 (警示)
            UIAlertAction *ac2 = [UIAlertAction actionWithTitle:@"退出账户" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
                //退出账户
                [WeakSelf exitAccount];
            }];
            
            
            //第二空取消  取消按钮总在最下
            UIAlertAction *ac3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
            [ac addAction:ac1];
            [ac addAction:ac2];
            [ac addAction:ac3];
            
            [self presentViewController:ac animated:YES completion:nil];
        } break;
        default:
            break;
    }
    
    
}



//清除缓存
- (void)clearCache{
    NSLog(@"清除缓存");
}


//退出账户
- (void)exitAccount{
    
    NSLog(@"退出账户");
}





- (IBAction)FanHuiButton:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}




- (NSArray *)MyTableArray{
    if (!_MyTableArray){
        _MyTableArray = [NSArray array];
    }
    return _MyTableArray;
}

@end
